{template 'common/header'}
{template 'common_css'}
<ul class="nav nav-tabs">
	<li{if $op == 'display' && $status==''} class="active"{/if}><a href="{php echo $this->createWebUrl('Radio', array('cid' => $cid))}">选项管理</a></li>
	<li{if $op == 'post' && !$id} class="active"{/if}><a href="{php echo $this->createWebUrl('Radio', array('cid' => $cid,'op' => 'post'))}">添加选项</a></li>
	{if !empty($id)}<li{if $op == 'detail'} class="active"{/if}><a>{$item['number']} 详细信息</a></li>{/if}
</ul>
{if $op=='display'}
<div class="main">
        <div class="panel panel-info">
        <div class="panel-heading">筛选</div>
            <div class="panel-body">
			<form action="" method="post" class="form-horizontal" role="form">
				<input type="hidden" name="c" value="site" />
				<input type="hidden" name="a" value="entry" />
				<input type="hidden" name="m" value="dayu_form_plugin_radio" />
				<input type="hidden" name="do" value="Radio" />
				<div class="form-group">
					<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">按标题搜索</label>
					<div class="col-sm-8 col-lg-8">
						<input class="form-control" name="title" id="" type="text" value="{$_GPC['title']}">
					</div>
						<div class="col-xs-12 col-sm-2 col-lg-2">
							<div class='btn-group'>
								<button class="btn btn-primary"><i class="fa fa-search"></i> 搜索</button>
							</div>
						</div>
				</div>
			</form>
        </div>
    </div>
	<div class="panel panel-default">
		<div class="panel-body table-responsive">
    <form action="" method="post" class="form-horizontal form" onsubmit="return formcheck(this)" id="form1">
	<div style="padding-top: 15px;">
        <table class="table table-hover">
			<input type="hidden" name="op" value="del" />
            <thead class="navbar-inner">
            <tr>
				<th class="text-center" style="width:44px;">ID</th>
				<th style="width:44px;">删?</th>
                <th class="text-left">标题</th>
                <th style="width:80px" class="text-center">状态</th>
                <th style="width:120px" class="text-left">添加时间</th>
                <th style="width:180px" class="text-right">操作</th>
            </tr>
            </thead>
            <tbody id="level-list">
            {loop $list $item}
            <tr>
				<td class="text-center">{$item['id']}</td>
				<td><input type="checkbox" name="kid[]" value="{$item['id']}" class=""></td>
                <td>{$item['title']}</td>
                <td class="text-center">
					<span class="label label-default {if $item['status']==1}label-success{/if}">{if $item['status']==1}启用{else}关闭{/if}</span>
                </td>
				<td class="text-left"><small>{php echo date('Y-m-d H:i',$item['createtime'])}</small></td>
                <td class="text-right">
					<a class="btn btn-sm btn-default" href="{php echo $this->createWebUrl('Radio', array('id'=>$item['id'],'cid' => $cid, 'op'=>'detail'))}" title="编辑选项：{$item['title']}"><i class="fa fa-edit"></i> 编辑</a>
					<a class="btn btn-sm btn-danger" href="{php echo $this->createWebUrl('Radio', array('id'=>$item['id'],'cid' => $cid, 'op'=>'delete'))}" title="删除选项：{$item['title']}" onclick="return confirm('删除选项：{$item['title']}，确认吗？') && confirm('确认并了解后果？');"><i class="fa fa-trash-o"></i> 删除</a>
                </td>
            </tr>
            {/loop}
		<tr>
			<td></td>
			<td><input type="checkbox" name="" onclick="var ck = this.checked;$(':checkbox').each(function(){this.checked = ck});"></td>
			<input name="token" type="hidden" value="{$_W['token']}" />
			<td colspan="4"><input type="submit" name="submit" class="btn btn-danger" value="批量删除"></td>
		</tr>
            </tbody>
        </table>
	</div>
    </form>
		{$pager}
        </div>
    </div>
</div>
	<script>
	require(['trade', 'bootstrap'], function(trade){
		trade.init();
		$('#form1').submit(function(){
			if($(":checkbox[name='kid[]']:checked").size() > 0){
				return confirm('删除后不可恢复，您确定删除吗？');
			}
			util.message('没有选择选项', '', 'error');
			return false;
		});
	});
	require(['bootstrap'],function($){
		$('.btn').hover(function(){
			$(this).tooltip('show');
		},function(){
			$(this).tooltip('hide');
		});
	});
	</script>
{else}
<div class="main">
    <div style="padding-top: 15px;">
	<form class="form-horizontal form" id="form2" action="" method="post" onSubmit="return checkdata();">
		<div class="panel panel-default">
			<div class="panel-heading">
				选项设置
			</div>
			<div class="panel-body">
				<div class="form-group">
					<label class="col-xs-12 col-sm-2 col-md-2 col-lg-2 control-label">标题</label>
					<div class="col-sm-9">
						<input type="text" name="title" class="form-control" value="{$item['title']}" />
					</div>
				</div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">选项图标</label>
                    <div class="col-xs-12 col-sm-9">
                         {php echo tpl_form_field_image('thumb',$item['thumb']);}
                    </div>
                </div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">选项图片展示</label>
					<div class="col-sm-9 col-xs-12">
						{php echo tpl_form_field_multi_image('album',$piclist)}
						<span class="help-block">WEUI系列皮肤暂不支持图片展示</span>
					</div>
				</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">启用状态</label>
				<div class="col-xs-12 col-sm-9">
				<div class="btn-group" data-toggle="buttons">					  
					<label class="btn btn-default {if empty($item) || $item['status'] == 1}active{/if}"><input type="radio" name="status" value="1" {if empty($item) || $item['status'] == 1} checked="checked"{/if} >启用</label>
					<label class="btn btn-default {if $item['status'] == '0'}active{/if}"><input type="radio" name="status" value="0" {if $item['status'] == '0'} checked="checked"{/if}>关闭</label>
				</div>
				</div>
			</div>
			</div>
		</div>
		<div class="form-group col-sm-12">
			<input type="hidden" name="token" value="{$_W['token']}" />
			<input type="hidden" name="id" value="{$id}" />
			<input type="submit" class="btn btn-primary col-lg-1" name="submit" value="提交" />
		</div>
	</form>
    </div>
</div>
<script>
</script>
{/if}
{template 'common/footer'}